<!-- 工单统计 -->
<template>
  <div class="work-order-box" v-loading="loading">
    <el-row :gutter="10">
      <el-col :xs="24" :sm="24" :md="12" :lg="6" :xl="6">
        <div class="data-item">
          <div class="num">{{ yearData }}</div>
          <div class="txt">年度工单</div>
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :md="12" :lg="6" :xl="6">
        <div class="data-item">
          <div class="num">{{ monthData }}</div>
          <div class="txt">月度工单</div>
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :md="12" :lg="6" :xl="6">
        <div class="data-item">
          <div class="num">{{ weekData }}</div>
          <div class="txt">周度工单</div>
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :md="12" :lg="6" :xl="6">
        <div class="data-item">
          <div class="num">{{ nowData }}</div>
          <div class="txt">今日工单</div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script setup lang="ts" name="WorkOrderBox">
import { ref, onMounted } from "vue";
import { findYearCreateRequest, findMonthCreateRequest, findWeekCreateRequest, findNowCreateRequest } from "@/api/modules/index";

const yearData = ref(0);
const monthData = ref(0);
const weekData = ref(0);
const nowData = ref(0);
const loading = ref(true);

onMounted(() => {
  // 年度工单
  findYearCreateRequest({}).then((res: any) => {
    yearData.value = res;
    loading.value = false;
  });
  // 月度工单
  findMonthCreateRequest({}).then((res: any) => {
    monthData.value = res;
  });
  // 周度工单
  findWeekCreateRequest({}).then((res: any) => {
    weekData.value = res;
  });
  // 今日工单
  findNowCreateRequest({}).then((res: any) => {
    nowData.value = res;
  });
});
</script>

<style scoped lang="scss">
.work-order-box {
  padding: 0 10px 10px;
  .data-item {
    box-sizing: border-box;
    padding: 15px 0 18px;
    margin-top: 10px;
    text-align: center;
    background-color: var(--el-menu-active-bg-color);
    background-size: 100% 100%;
    border-radius: 10px;
    transition: all 0.3s;
  }
  .num {
    font-size: 20px;
    font-weight: bold;
    color: $primary-color;
  }
  .txt {
    margin-top: 5px;
    font-size: 14px;
  }
}
</style>
